package space.sakana.edusysback.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import space.sakana.edusysback.entity.Teacher;

import java.util.List;

@Mapper
public interface TeacherMapper {

    @Select("select `id`, `username`, `password`, `name`, `token` from teacher where `id`=#{id};")
    Teacher selectTeacherById(int id);

    @Select("select `id`, `username`, `password`, `name`, `token` from teacher;")
    List<Teacher> selectAllTeacher();

    @Select("select `id`, `username`, `password`, `name`, `token` from teacher where `username`=#{username};")
    Teacher selectTeacherByUsername(String username);

    @Insert("insert into teacher(`username`, `password`, `name`) values(#{username}, #{password}, #{name});")
    int insertTeacher(Teacher teacher);

    @Update("update teacher set `username`=#{username}, `password`=#{password}, `name`=#{name}, `token`=#{token} where `id`=#{id};")
    int updateTeacher(Teacher teacher);

}
